/*  1:   */ package tt.dz.web.controller.resource;
/*  2:   */ 
/*  3:   */ import com.alibaba.fastjson.JSON;
/*  4:   */ import java.util.ArrayList;
/*  5:   */ import java.util.List;
/*  6:   */ import javax.annotation.Resource;
/*  7:   */ import javax.servlet.http.HttpServletRequest;
/*  8:   */ import org.springframework.stereotype.Controller;
/*  9:   */ import org.springframework.web.bind.annotation.RequestMapping;
/* 10:   */ import org.springframework.web.bind.annotation.ResponseBody;
/* 11:   */ import tt.dz.biz.service.resource.ResourceService;
/* 12:   */ import tt.dz.common.LogUtil;
/* 13:   */ import tt.dz.vo.ResourceVO;
/* 14:   */ import tt.dz.vo.ResponseModle;
/* 15:   */ import tt.dz.vo.RoleResourceVO;
/* 16:   */ import tt.dz.vo.RoleVO;
/* 17:   */ import tt.dz.web.controller.BaseController;
/* 18:   */ import tt.dz.webframe.authen.service.AuthService;
/* 19:   */ 
/* 20:   */ @Controller
/* 21:   */ public class ResourceController
/* 22:   */   extends BaseController
/* 23:   */ {
/* 24:   */   @Resource(name="tt.dz.webframe.authen.service.authService")
/* 25:   */   private AuthService authService;
/* 26:   */   @Resource(name="resourceService")
/* 27:   */   private ResourceService resourceService;
/* 28:   */   
/* 29:   */   @RequestMapping(value={"/queryResourceByRole"}, produces={"application/json;charset=UTF-8"})
/* 30:   */   @ResponseBody
/* 31:   */   public String queryResourceByRole(HttpServletRequest request)
/* 32:   */   {
/* 33:41 */     ResponseModle responseModle = null;
/* 34:   */     try
/* 35:   */     {
/* 36:43 */       RoleVO roleVO = new RoleVO();
/* 37:44 */       roleVO.setRoleId(request.getParameter("roleId"));
/* 38:45 */       List<ResourceVO> resources = this.resourceService.queryResourceByRole(roleVO);
/* 39:46 */       responseModle = new ResponseModle("success", resources);
/* 40:   */     }
/* 41:   */     catch (Exception e)
/* 42:   */     {
/* 43:48 */       LogUtil.error("查询资源异常", e);
/* 44:49 */       responseModle = new ResponseModle("error", new ArrayList());
/* 45:   */     }
/* 46:51 */     return JSON.toJSONString(responseModle);
/* 47:   */   }
/* 48:   */   
/* 49:   */   @RequestMapping(value={"/queryUnAllotResourceByRole"}, produces={"application/json;charset=UTF-8"})
/* 50:   */   @ResponseBody
/* 51:   */   public String queryUnAllotResourceByRole(HttpServletRequest request)
/* 52:   */   {
/* 53:62 */     ResponseModle responseModle = null;
/* 54:   */     try
/* 55:   */     {
/* 56:64 */       RoleVO roleVo = new RoleVO();
/* 57:65 */       roleVo.setRoleId(request.getParameter("roleId"));
/* 58:66 */       List<ResourceVO> resources = this.resourceService.queryUnAllotResourceByRole(roleVo);
/* 59:67 */       responseModle = new ResponseModle("success", resources);
/* 60:   */     }
/* 61:   */     catch (Exception e)
/* 62:   */     {
/* 63:69 */       LogUtil.error("查询资源异常", e);
/* 64:70 */       responseModle = new ResponseModle("error", new ArrayList());
/* 65:   */     }
/* 66:72 */     return JSON.toJSONString(responseModle);
/* 67:   */   }
/* 68:   */   
/* 69:   */   @RequestMapping(value={"/modifyRoleResource"}, produces={"application/json;charset=UTF-8"})
/* 70:   */   @ResponseBody
/* 71:   */   public String modifyRoleResource(HttpServletRequest request)
/* 72:   */   {
/* 73:81 */     boolean excuteFlag = false;
/* 74:   */     try
/* 75:   */     {
/* 76:84 */       List<RoleResourceVO> roleResourceVOs = JSON.parseArray(request.getParameter("roleResourceVOs"), RoleResourceVO.class);
/* 77:   */       
/* 78:86 */       excuteFlag = this.resourceService.batchModifyRoleResource(roleResourceVOs);
/* 79:87 */       this.authService.refreshResourceAuth();
/* 80:   */     }
/* 81:   */     catch (Exception e)
/* 82:   */     {
/* 83:89 */       LogUtil.error("变更角色资源异常", e);
/* 84:   */     }
/* 85:91 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, null));
/* 86:   */   }
/* 87:   */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.resource.ResourceController
 * JD-Core Version:    0.7.0.1
 */